home *** CD-ROM | disk | FTP | other *** search
-
-
-
- Psigaction(2) May 1, 1992 Psigaction(2)
-
-
- N✓NA✓AM✓ME✓E
- Psigaction - change the way a signal is handled
-
- S✓SY✓YN✓NO✓OP✓PS✓SI✓IS✓S
- #include <signal.h>
-
- LONG Psigaction(WORD sig, struct sigaction *act, struct sigaction *oact);
-
- D✓DE✓ES✓SC✓CR✓RI✓IP✓PT✓TI✓IO✓ON✓N
- _✓P_✓s_✓i_✓g_✓a_✓c_✓t_✓i_✓o_✓n changes the handling of the signal indicated by
- _✓s_✓i_✓g (which must be between 1 and 31; symbolic constants
- for symbols are defined in the file signal.h).
-
-
- If _✓a_✓c_✓t is non-zero, then it is assumed to point to a
- structure describing the signal handling behavior. This
- structure has the following members:
- struct sigaction {
- LONG sa_handler;
- LONG sa_mask;
- WORD sa_flags;
- }
- If _✓s_✓a_✓__✓h_✓a_✓n_✓d_✓l_✓e_✓r is SIG_DFL, then the default action for the
- signal will occur when the signal is delivered to the pro-
- cess.
-
-
- If _✓s_✓a_✓__✓h_✓a_✓n_✓d_✓l_✓e_✓r is SIG_IGN, then the signal will be ignored
- by the process, and delivery of the signal will have no
- noticeable effect (in particular, the signal will not
- interrupt the _✓P_✓a_✓u_✓s_✓e or _✓P_✓s_✓i_✓g_✓p_✓a_✓u_✓s_✓e system calls, q.v.). If
- the signal is pending at the time of the _✓P_✓s_✓i_✓g_✓n_✓a_✓l call, it
- is discarded.
-
-
- If _✓s_✓a_✓__✓h_✓a_✓n_✓d_✓l_✓e_✓r is some other value, it is assumed to be the
- address of a user function that will be called when the
- signal is delivered to the process. The user function is
- called with a single LONG argument on the stack, which is
- the number of the signal being delivered (this is done so
- that processes may use the same handler for a number of
- different signals). While the signal is being handled, it
- is blocked from delivery; thus, signal handling is "reli-
- able" (unlike Version 7 and early System V Unix implemen-
- tations, in which delivery of a second signal while it was
- being handled could kill the process). The set of signals
- specified in _✓s_✓a_✓__✓m_✓a_✓s_✓k are also blocked from delivery while
- the signal handler is executing. Note that, unlike in
- some versions of Unix, the signal handling is not reset to
- the default action before the handler is called; it
- remains set to the given signal handler.
-
-
- The signal handler must either return (via a normal 680x0
-
-
-
- Version 0.95 MiNT Programmer's Manual 1
-
-
-
-
-
- Psigaction(2) May 1, 1992 Psigaction(2)
-
-
- rts instruction) or call the _✓P_✓s_✓i_✓g_✓r_✓e_✓t_✓u_✓r_✓n system call to
- indicate when signal handling is complete; in both cases,
- the signal will be unblocked. Psigreturn also performs
- some internal clean-up of the kernel stack that is neces-
- sary if the signal handler is not planning to return (for
- example, if the C longjmp() function is to be used to con-
- tinue execution at another point in the program).
-
-
- Signal handlers may make any GEMDOS, BIOS, or XBIOS system
- calls freely. GEM AES and VDI calls should not be made in
- a signal handler.
-
-
- The _✓s_✓a_✓__✓f_✓l_✓a_✓g_✓s field specifies additional, signal-specific
- signal handling behavior. If _✓s_✓i_✓g is SIGCHLD, and the
- _✓S_✓A_✓__✓N_✓O_✓C_✓L_✓D_✓S_✓T_✓O_✓P bit is set in _✓s_✓a_✓__✓f_✓l_✓a_✓g_✓s, then the SIGCHLD sig-
- nal is sent to this process only when one of its children
- terminates (and not when a child is suspended by a job
- control signal).
-
-
- The _✓o_✓a_✓c_✓t argument to _✓P_✓s_✓i_✓g_✓a_✓c_✓t_✓i_✓o_✓n, if non-zero, specifies a
- structure that will be set to reflect the signal handling
- for _✓s_✓i_✓g that was current at the time of the _✓P_✓s_✓i_✓g_✓a_✓c_✓t_✓i_✓o_✓n
- system call.
-
-
- Note that calling _✓P_✓s_✓i_✓g_✓a_✓c_✓t_✓i_✓o_✓n to change behavior of a sig-
- nal has the side effect of unmasking that signal, so that
- delivery is possible. This is done so that processes may,
- while handling a signal, reset the behavior and send them-
- selves another instance of the signal, for example in
- order to suspend themselves while handling a job control
- signal. Signal handling is preserved across _✓P_✓f_✓o_✓r_✓k and
- _✓P_✓v_✓f_✓o_✓r_✓k calls. Signals that are ignored by the parent are
- also ignored by the child after a _✓P_✓e_✓x_✓e_✓c call; signals that
- were being caught for handling in a function are reset in
- the child to the default behavior.
-
-
- R✓RE✓ET✓TU✓UR✓RN✓NS✓S
- 0 on success
-
-
- ERANGE if _✓s_✓i_✓g is not a legal signal.
-
-
- EACCDN if the signal may not be caught by the user
-
-
- S✓SE✓EE✓E A✓AL✓LS✓SO✓O
- _✓P_✓k_✓i_✓l_✓l(2), _✓P_✓s_✓i_✓g_✓b_✓l_✓o_✓c_✓k(2), _✓P_✓s_✓i_✓g_✓n_✓a_✓l(2), _✓P_✓s_✓i_✓g_✓r_✓e_✓t_✓u_✓r_✓n(2)
-
-
-
-
- Version 0.95 MiNT Programmer's Manual 2
-
-
-
-
-
- Psigaction(2) May 1, 1992 Psigaction(2)
-
-
- B✓BU✓UG✓GS✓S
- Signal handling can be nested only a small (around 3) num-
- ber of times, i.e. if 4 signals are delivered to a pro-
- cess, and the process has established handlers for all 4,
- and none of the handlers has returned or called _✓P_✓s_✓i_✓g_✓r_✓e_✓-
- _✓t_✓u_✓r_✓n,
- then there is a very good chance of a stack overflow
- killing the process off. In practice, this is unlikely to
- happen.
-
-
- A✓AU✓UT✓TH✓HO✓OR✓R
- Alex Kiernan
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Version 0.95 MiNT Programmer's Manual 3
-
-
-